package com.glodon.fansi.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.fansi.db.dao.UserMapper;
import com.glodon.fansi.db.model.User;

@Service
public class UserService {
	@Autowired
	private UserMapper userMapper;
	private static final Logger LOGGER = LoggerFactory
			.getLogger(UserService.class);

	public List<User> selectByParam(User u) {
		return userMapper.selectByColoum(u);
	}

	public User login(String account, String password) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("account", account);
		map.put("password", DigestUtils.md5Hex(password));
		LOGGER.debug("用户{} 请求登录", account);
		return userMapper.login(map);
	}

	public User selectByAccount(String account) {

		return userMapper.selectByAccount(account);
	}
	public User selectById(String id) {

		return userMapper.selectByPrimaryKey(id);
	}
	public int updateByPrimaryKeySelective(User user) {

		return userMapper.updateByPrimaryKeySelective(user);
	}
}
